//
//  YuYueOrderDetailFooterView.m
//  FD
//
//  Created by xiaofang wang on 2018/11/12.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "YuYueOrderDetailFooterView.h"
@interface YuYueOrderDetailFooterView()
/**左边的按钮*/
@property (nonatomic,strong) UIButton *leftBtn;
/**右边的按钮*/
@property (nonatomic,strong) UIButton *rightBtn;
@end

@implementation YuYueOrderDetailFooterView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
        self.backgroundColor = kMainLightGrayColor; //浅灰色
    }
    return self;
}
- (void)setupView {
    [self addSubview:self.leftBtn];
    [self addSubview:self.rightBtn];
}

- (void)layoutSubviews {
    [super layoutSubviews];
   
    [self.leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(40);
        make.size.mas_equalTo(CGSizeMake(80, 30));
        make.centerY.equalTo(self.mas_centerY);
    }];
    
    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 30));
        make.right.equalTo(self.mas_right).offset(-40);
        make.centerY.equalTo(self.mas_centerY);
    }];
}

//geter


#pragma mark - data
- (UIButton *)leftBtn {
    if (!_leftBtn) {
//        _leftBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
//        _leftBtn.backgroundColor = [UIColor redColor];
        _leftBtn = [self createBtnWithTarget:self action:@selector(clickLeftBtnAction:) title:NSLocalizedString(LianXiShangJia, @"联系商家")];
    }
    return _leftBtn;
}


- (UIButton *)rightBtn {
    if (!_rightBtn) {
//        _rightBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
//        _rightBtn.backgroundColor = [UIColor greenColor];
//        _rightBtn = [self createBtnWithTarget:self action:@selector(clickRightBtnAction:) title:@"立即支付"];
        _rightBtn = [self createBtnWithTarget:self action:@selector(clickRightBtnAction:) title:NSLocalizedString(L_Order_Evaluate, @"评价")];
    }
    return _rightBtn;
}


- (UIButton *)createBtnWithTarget:(id)target action:(SEL)action title:(NSString *)title {
    
    UIButton *btn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [btn setTitle:title forState:(UIControlStateNormal)];
    [btn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [btn setTitleColor:[UIColor lightGrayColor] forState:(UIControlStateSelected)];
    [btn addTarget:target action:action forControlEvents:(UIControlEventTouchUpInside)];
    btn.layer.masksToBounds = YES;
    btn.layer.cornerRadius = 5;
    btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    btn.layer.borderWidth = 1.0;
    btn.backgroundColor  = [UIColor whiteColor];
    
    return btn;
}

#pragma mark - 点击事件
- (void)clickLeftBtnAction:(UIButton *)btn
{
    if (self.clickLeftBlock) {
        self.clickLeftBlock();
    }
}
- (void)clickRightBtnAction:(UIButton *)btn
{
    if (self.clickRightBlock) {
        self.clickRightBlock();
    }
}

@end
